package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Mycomment;
import cn.wolfcode.trip.base.domain.StrategyCatalog;
import cn.wolfcode.trip.base.mapper.MycommentMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IMycommentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MycommentServiceImpl implements IMycommentService {

    @Autowired
    private MycommentMapper mycommentMapper;


    @Override
    public void saveOrUpdate(Mycomment mycomment) {
        if(mycomment.getId()!=null){
            mycommentMapper.updateByPrimaryKey(mycomment);
        }else{
            mycommentMapper.insert(mycomment);
        }
    }


    @Override
    public List<Mycomment> selectAll() {
        return mycommentMapper.selectAll();
    }

    @Override
    public PageInfo query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),qo.getOrderBy());
        List<Mycomment> list = mycommentMapper.selectForList(qo);
        return new PageInfo(list);
    }
}
